<template>
	<uni-section title="场景选择" type="line">
	</uni-section>
	<view v-if="CurrentDevice==true" class="uni-stat--x flex p-1015">
		<view class="uni-stat--app-select">
			<uni-data-select v-if="CurrentDevice==true" style="padding: 10px;" v-model="no" :localdata="deviceList" :clear="true"
				@change="Changedevice" label="场景列表"></uni-data-select>
			<uni-data-select v-if="CurrentType==true" style="padding: 10px;" v-model="value" :localdata="Datatype" @change="Changetype"
				label="数据类型"></uni-data-select>
		</view>
	</view>

	<uni-table v-if="CurrentType==true" ref="Items" :loading="loading" border stripe type="" emptyText="暂无更多数据">
		<uni-tr>
			<uni-th width="120" align="center">场景编号</uni-th>
			<uni-th width="100" align="center">原图</uni-th>
			<uni-th width="100" align="center">识别图</uni-th>
			<uni-th align="200">时间</uni-th>
		</uni-tr>
		<uni-tr v-for="(item, index) in Scene" :key="index">
			<uni-td>{{deviceList[item.d_no].text }}</uni-td>
			<uni-td>
				<view style="background-color: #f5f7fa;padding: 10px;border-radius: 15px;">
					<uni-link :href="item.field6" text="https://uniapp.dcloud.io/" showUnderLine="false"
						color="black">跳转</uni-link>
					<uni-icons type="info" size="15" style="position: relative;top: 0%;left: 0%;"></uni-icons>
				</view>
			</uni-td>
			<uni-td>
				<view style="background-color: #f5f7fa;padding: 10px;border-radius: 15px;">
					<uni-link :href="item.field5" text="https://uniapp.dcloud.io/" showUnderLine="false"
						color="black">跳转</uni-link>
					<uni-icons type="info" size="15" style="position: relative;top: 0%;left: 0%;"></uni-icons>
				</view>
			</uni-td>
			<uni-td align="center">{{ item.c_time }}</uni-td>
		</uni-tr>
	</uni-table>
</template>

<script>
	export default {
		data() {
			return {
				value: -1,
				d_type: -1,
				no: -1,
				loading: false,
				Datatype: [{
						value: 0,
						text: "图片"
					},
					{
						value: 1,
						text: "视频"
					},
				],
			}
		},
		props: {
			socket: {
				type: Object,
				require: true,
			},
			deviceList: {
				type: Object,
				required: true
			},
			Scene: {
				type: Object,
				required: true
			},
			CurrentDevice: {
				type:Boolean
			},
			CurrentType: {
				type: Boolean
			},
		},
		methods: {
			Changetype(ed) {
				this.d_type = ed;
				let t = this.no == -1 ? -1 : this.deviceList[this.no].value;
				this.socket.send({
					data: JSON.stringify({
						d_no: t,
						type: 'device',
						value: 'Data',
						d_type: this.d_type + 2,
					})
				})
			},
			Changedevice(e) {
				this.no = e;
				this.socket.send({
					data: JSON.stringify({
						d_no: this.deviceList[this.no].value,
						type: 'device',
						value: 'Data',
						P_type: 'Changedevice',
						d_type: this.d_type == -1 ? this.d_type : this.d_type + 2,
					})
				})
			}
		}
	}
</script>

<style>
	.uni-stat--x {
		border-radius: 4px;
		box-shadow: -1px -1px 5px rgba(0, 0, 0, .1);
		margin-bottom: 15px;
	}

	.flex {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
	}

	.p-1015 {
		padding: 10px 15px;
	}

	.uni-stat--app-select {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		width: 900px;
		max-width: 100%;

	}
</style>